package com.fyzk.betzhushu.gp11xuan5;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

import com.fyzk.activity.lottery.shuzicai.BallInfo;
import com.fyzk.betzhushu.ZhuShuBase;

public class Gp11xuan5_ZhiXuan extends ZhuShuBase{
	
	private int num = 2;
	
	public Gp11xuan5_ZhiXuan(int num){
		this.num = num;
	}

	@Override
	public long betZhuShu(List<List<BallInfo>> balls) {
		int dan = 0;
		int hong1 = 0;
		int hong2 = 0;
		int hong3 = 0;
		
		List<BallInfo> infos1 = balls.get(1);
		List<BallInfo> infos2 = balls.get(2);
		List<BallInfo> infos3 = balls.get(3);
		List<String> checkNums = new ArrayList<String>();
		int zhuShu = 0;
		for (int i = 0; i < infos1.size(); i++) {
			if (infos1.get(i).isSelected()) {
				String checkFirst = infos1.get(i).getNum();
				for (int j = 0; j < infos2.size(); j++) {
					if (infos2.get(j).isSelected()) {
						String checkTwo = infos2.get(j).getNum();
						if (num == 2) {
							if (!checkFirst.equals(checkTwo)) {
								zhuShu++;
							}
						}else{
							for (int k = 0; k < infos3.size(); k++) {
								if (infos3.get(k).isSelected()) {
									String checkThree = infos3.get(k).getNum();
									if (!checkFirst.equals(checkTwo) && !checkFirst.equals(checkThree) && !checkThree.equals(checkTwo)) {
										zhuShu++;
									}
									
								}
							}
						}
					}
				}
				
			}
		}
		
		
		return zhuShu;
	}
	
	/**
	 * 计算注数(任选n)
	 */
	private long getZhuShu_common(int hong){
		if (hong < num) {
			return 0;
		}else{
			BigInteger big = c_x_y(hong).divide(c_x_y(num)).divide(c_x_y(hong - num));
			return  big.longValue();
		}
	}
	
	private BigInteger c_x_y(int n){
		BigInteger big = new BigInteger(""+n);
		
		return (n == 0) ? new BigInteger("1") : big.multiply(c_x_y(n - 1)) ;
	}

}
